/*
 * @Author: lg
 * @Date: 2024-01-15 18:16:01
 * @LastEditors: zhouxuan
 * @LastEditTime: 2024-08-21 15:36:34
 * @Description:
 * @FilePath: \lg-cli\lib\create.js
 */
const path = require('path');
const fs = require('fs-extra');
const inquirer = require('inquirer');
const Generator = require('./generator');
const checkExists = require('../../utils/check-exists');

// 1. 对外暴露出一个方法用来接收用户要创建的文件项目名以及参数
module.exports = async function (name, options) {
  // // 判断项目是否存在
  const cwd = process.cwd();
  const targetAir = path.join(cwd, name);

  const res = await checkExists(name, options);
  console.log('res-----', res);
  if (res) {
    return false;
  }

  // 新建模板
  const generator = new Generator(name, targetAir);
  generator.create();
};
